﻿@{
    Layout = null;
    var eid = ViewBag.eid;
}

<style>
    .modal-content
    {
        background: #FFFFFF;
    }

    .SourceNodeLeftChild
    {
        border: 1px solid #E5E5E5;
        margin-bottom: 10px;
        display: inline-block;
        min-width: 95%;
    }

    #gridTreeDiv_1 td
    {
        text-align: left;
    }
</style>
<script src="~/Scripts/tableTree/TableTree4J.js"></script>
<div  class="padding-bottom-50">
    <input type="hidden" id="classifyId" value="1" />
    <!-- Nav tabs -->
    <ul id="myTab" class="nav nav-tabs">
        <li class="CategoryTemplate active">
            <a href="#CategoryTemplate" data-toggle="tab" onclick="$.MGJ.FromTemplet.TabClick(1)">
                类目模板
            </a>
        </li>
        <li><a href="#MyTemplate" data-toggle="tab" onclick="$.MGJ.FromTemplet.TabClick(0)">我的模板</a></li>
    </ul>
    <div class="tab-content margin-top-10" style="">
        <div id="gridTreeDiv_1" class="col-xs-4 col-md-4" style="max-height: 500px; z-index: 99999; overflow-y: auto; "></div>
        <div id="tableDiv" class="col-xs-8 col-md-8">
            <!-- Tab panes -->
            <table class="table table-hover table-bordered  " style="text-align:center">
                <thead>
                    <tr>
                        <th width="15">选择</th>
                        <th>模板编号</th>
                        <th>模板名称</th>
                        @*<th>适用产品</th>
                            <th>所属类目</th>*@
                        <th>备注</th>
                        <th>创建时间</th>
                    </tr>
                </thead>
                <tbody id="NodeTb" style="display:none;" binding="{'pageId':'NodeTbPager','pageCallback':'$.MGJ.FromTemplet.Ajax_GetNodeTable','emptyHtml':Node_EmptyHtml}">
                    <tr>
                        <td width="15"><input type="radio" name="tdRadio" binding="{'value':'TempletId'}"></td>
                        <td binding="{'text':'Code'}"></td>
                        <td binding="{'text':'Name'}"></td>
                        @*<td binding="{'text':'ProductName'}"></td>
                            <td binding="{'text':'ClassifyName'}"></td>*@
                        <td binding="{'text':'Remark'}"></td>
                        <td binding="{'text':'ChangeDate','textHandle':'datetime'}"></td>
                    </tr>
                </tbody>

            </table>
            <div id="NodeTbPager"></div>
        </div>
    </div>
</div>

<script>
    var ColspanNub = $(".table.table-hover.table-bordered").find("tr").children("td").length
    window.Node_EmptyHtml = '<tr><td colspan="' + ColspanNub + '"><p class="no-result">无符合条件的数据结果</p></td></tr>';



    $(document).ready(function () {
        $.MGJ.FromTemplet.Ajax_GetTemplateTree();
    });

    $.MGJ.FromTemplet = [];
   (function () {
       var _this = $.MGJ.FromTemplet;
       $.extend($.MGJ.FromTemplet, {

           conditionModel: {
               pageIndex: 1,
               pageSize: 15,
               searchKey: null,//查询条件
               showSys: 1,  //我的模板：0  系统模板：1 我的模板和系统模板：2
               classifyId: 0 // 节点ID  等于0查询全部
           },

           //获取模版列表
           Ajax_GetNodeTable: function (Pindex) {

               _this.conditionModel.pageIndex = Pindex;
               _this.conditionModel.classifyId = $("#classifyId").val();

               $.L.ajaxHandle({
                   url: ACTION_URL("GetTempletListBySearch", "OriginsTemplet"),
                   data: _this.conditionModel,
                   success: function (data) {
                       $("#NodeTb").L_bindingDataList(data);
                   }
               })
           },


           //获取目录树
           Ajax_GetTemplateTree: function () {

              _this.Ajax_GetNodeTable(1);

               $.L.ajaxHandle({
                   url: ACTION_URL("getClassifyTree", "Product"),
                   success: function (data) {

                       gridTree = new TableTree4J("gridTree", "../");
                       gridTree.tableDesc = "<table border=\"1\" class=\"GridView table table-bordered \" width=\"100%\" id=\"table1\" cellspacing=\"0\" cellpadding=\"0\" style=\"border-collapse: collapse\"  bordercolordark=\"#C0C0C0\" bordercolorlight=\"#C0C0C0\" bordercolorlight=\"#C0C0C0\" >";
                       var headerDataList = new Array("菜单名");
                       var widthList = new Array("20%", "30%", "10%", "30%");
                       gridTree.setHeader(headerDataList, -1, widthList, true, "tittle-bg");
                       //设置列样式
                       gridTree.gridHeaderColStyleArray = new Array("", "", "", "centerClo1");
                       gridTree.gridDataCloStyleArray = new Array("", "", "", "centerClo2");
                       $("#sel_parent_meun").html("<option value='0'>无</option>");
                       $(data).each(function (i, d) {
                           var MenuName = "";
                           if (d.PID != 0) {

                               MenuName += "<span onclick='javascript:$.MGJ.FromTemplet.Ajax_GetNodeTable(1," + _this.conditionModel.showSys + "," + d.ID + ")'>" + d.Name + "</span>";
                           }
                           else {
                               MenuName += "<span>" + d.Name + "</span>";
                           }

                           var dataList = new Array(MenuName);

                           //1：对象，2：编号，3：父节点 默认为0，null，5:顺序
                           gridTree.addGirdNode(dataList, d.ID, d.PID == 0 ? -1 : d.PID, null, d.Sequence);
                           //$("#sel_parent_meun").append("<option value='" + d.ID + "'>" + d.MenuName + "</option>");
                       });
                       gridTree.printTableTreeToElement("gridTreeDiv_1");
                   }
               })
           },

           TabClick: function (showSys) {
               _this.conditionModel.showSys = showSys;
               _this.Ajax_GetTemplateTree();
           }


       });
   })(jQuery);



</script>